import 'package:flutter/material.dart';
import 'package:live_client/views/components/BottomBar.dart';
import 'package:live_client/views/components/BottomBarProvider.dart';
import 'package:live_client/views/page/main/Home.dart';
import 'package:live_client/views/page/main/Live.dart';
import 'package:live_client/views/page/main/Mine.dart';
import 'package:provider/provider.dart';

class NavigationMain extends StatefulWidget {
  @override
  _NavigationMainState createState() => _NavigationMainState();
}

class _NavigationMainState extends State<NavigationMain> {
  @override
  void dispose() {
    super.dispose();
  }

  /// extendBody = true 凹嵌透明，需要处理底部 边距
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider<BottomBarProvider>(
      create: (_) => BottomBarProvider(),
      builder: (context, child) {
        BottomBarProvider bottomBarProvider =
            context.watch<BottomBarProvider>();
        return Scaffold(
          extendBody: false,
          floatingActionButtonLocation:
              FloatingActionButtonLocation.centerDocked,
          body: PageView(
            // 禁止 PageView 滑动
            physics: const NeverScrollableScrollPhysics(),
            controller: bottomBarProvider.controller,
            children: <Widget>[
              Home(),
              Live(),
              Mine(),
            ],
          ),
          bottomNavigationBar: BottomBar(provider: bottomBarProvider),
        );
      },
    );
  }
}
